﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using xVal.ServerSide;
using System.Web.Mvc;

namespace Northwinddemo.BusinessLayer.Models
{
    public static class RulesExceptionExtensions
    {
        
        public static void CopyToModelState(this RulesException rulesException, ModelStateDictionary modelState, string prefix)
        {
            foreach (var errorInfo in rulesException.Errors)
            {
                modelState.AddModelError(prefix + "." + errorInfo.PropertyName, errorInfo.ErrorMessage);
            }
        }

    }
}
